package name.huzhenbo.java.algorithm.calculation;

class AccumulatorThree {
    public static AccumulatorThree getInstance() {
        return AccumulatorThreeHolder.instance;
    }

    private AccumulatorThree() {
    }

    public int go(int n) {
        if (n <= 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        return go(n - 1) + go(n - 2) + go(n - 3);
    }

    private static class AccumulatorThreeHolder {
        static final AccumulatorThree instance = new AccumulatorThree();
    }
}
